-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-42538][CONNECT] Make sql.functions#lit function support more types
#40143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Some other things to do, will continue tomorrow |
| } | ||
| } | ||
|
|
||
| private def literalToColumn(literal: Literal): Column = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this. In fact for the next Spark release we will be removing the Catalyst dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we should remove case v: Literal => literalToColumn(v) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should. Sorry about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let me update the code
| case v: Array[Byte] => createLiteral(_.setBinary(ByteString.copyFrom(v))) | ||
| case v: collection.mutable.WrappedArray[_] => lit(v.array) | ||
| case v: LocalDate => createLiteral(_.setDate(v.toEpochDay.toInt)) | ||
| case v: UTF8String => createLiteral(_.setString(v.toString)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is internal API. Can you remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
|
@LuciferYang thanks for the PR! Which datatypes are we still missing? I think we still some collection support? |
|
I refer spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala Lines 64 to 102 in 87e3d56
the missing is |
|
A couple of things:
|
|
Oh and if it becomes too large I am fine with merging this first, and doing array in a follow-up. |
|
hmm... If I understand correctly, the current Literal does not support any collection type? Do we need to add some message types to support them? spark/connector/connect/common/src/main/protobuf/spark/connect/expressions.proto Lines 149 to 175 in 87e3d56
|
|
lol, no it does not. Let's just implement what we support, and do the rest in a different PR. |
|
OK |
I hope we can merge this pr first if no other need to change. In addition, I need to go to bed as soon as possible. It's 1:00 in my time zone :) |
|
go to sleep! |
|
@hvanhovell Is there anything else can help Scala Client? @panbingkun told me that he also wanted to take some work related to connect. |
|
@LuciferYang @panbingkun that would be great! I will create an epic, with a bunch of todo's. |
|
Is there anything else need change this pr? |
|
@LuciferYang can you update your PR? |
hvanhovell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@LuciferYang @panbingkun I created an epic with a bunch of things you can pick up: https://issues.apache.org/jira/browse/SPARK-42554 |
|
LGTM but please rebase this PR to solve conflict. |
|
Merging to master/3.4. Thanks! |
… types ### What changes were proposed in this pull request? This pr aims add more types support of `sql.functions#lit` function, include: - Decimal - Instant - Timestamp - LocalDateTime - Date - Duration - Period - CalendarInterval ### Why are the changes needed? Make ·sql.functions#lit· function support more types ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Add new test - Manual checked new case with Scala-2.13 Closes #40143 from LuciferYang/functions-lit. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Herman van Hovell <herman@databricks.com> (cherry picked from commit 2a4aab7) Signed-off-by: Herman van Hovell <herman@databricks.com>
… types ### What changes were proposed in this pull request? This pr aims add more types support of `sql.functions#lit` function, include: - Decimal - Instant - Timestamp - LocalDateTime - Date - Duration - Period - CalendarInterval ### Why are the changes needed? Make ·sql.functions#lit· function support more types ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Add new test - Manual checked new case with Scala-2.13 Closes apache#40143 from LuciferYang/functions-lit. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Herman van Hovell <herman@databricks.com> (cherry picked from commit 2a4aab7) Signed-off-by: Herman van Hovell <herman@databricks.com>
What changes were proposed in this pull request?
This pr aims add more types support of
sql.functions#litfunction, include:Why are the changes needed?
Make ·sql.functions#lit· function support more types
Does this PR introduce any user-facing change?
No
How was this patch tested?